#include<iostream>
#include<vector>
using namespace std;

vector<int> merge(const vector<int> &list1, const vector<int> &list2)
{
	vector<int> vm;

	auto it1 = list1.begin(), it2 = list2.begin();

	while(it1 != list1.end() && it2 != list2.end())
    {
		if(*it1 < *it2)
			vm.push_back(*it1++);
		else
			vm.push_back(*it2++);
	}

	while(it1 != list1.end())
		vm.push_back(*it1++);

	while(it2 != list2.end())
		vm.push_back(*it2++);

	return vm;
}

int main()
{
	vector<int> v1 = {2, 3, 4, 6};
	vector<int> v2 = {1, 3, 5, 7, 9, 13};
	vector<int> v3 = merge(v1, v2);

	for(size_t i=0; i<v1.size(); i++) cout << v1[i] << " ";
	cout << endl;

	for(size_t i=0; i<v2.size(); i++) cout << v2[i] << " ";
	cout << endl;

	for(size_t i=0; i<v3.size(); i++) cout << v3[i] << " ";
	cout << endl;

	return 0;
}

